﻿CREATE PROCEDURE [dbo].[text_BookStatistic_Insert]
	@url NVARCHAR(MAX)
	,@userId UNIQUEIDENTIFIER
AS
BEGIN
	SET @url = LTRIM(RTRIM(LOWER(@url)))

	DECLARE @bookTreeId BIGINT

	SELECT @bookTreeId = [BookTreeId]
	FROM [dbo].[text_BookTree_Cache]
	WHERE [Url] = @url

	IF @bookTreeId IS NOT NULL
	BEGIN
		INSERT INTO [dbo].[text_BookStatistic] ([UserId], [BookTreeId])
		VALUES (@userId, @bookTreeId)
	END
END